/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tolls;

import avenue.MyWindowEvent;
import avenue.Session;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.swing.JOptionPane;
import model.DBManager;
import model.Payment;
import model.Vehicle;
import java.util.Date;

/**
 *
 * @author Aggelos
 */
public class PaymentForm extends javax.swing.JFrame {

    /**
     * Creates new form PaymentForm
     */
    public PaymentForm() {
        em = DBManager.em;
        if ( !em.getTransaction().isActive()){
            em.getTransaction().begin();
        }
        editable=true;
        initComponents();
         setLocationRelativeTo(null);
    }
       
    public PaymentForm(Vehicle v,Boolean editable) {
        em = DBManager.em;
        vehicle1 = v;
         
        if ( !em.getTransaction().isActive()){
            em.getTransaction().begin();
        }
        vehicle1=v;
        this.editable=editable;
        initComponents();
        setLocationRelativeTo(null);
        jTextField1.setText(String.valueOf(vehicle1.getCardId().getBarcode()));
        jTextField2.setText(vehicle1.getRegNumber());
       try{
            updateFields();
        }
        catch(Exception ex){
           JOptionPane.showMessageDialog(rootPane,"Δεν έχουν εισαχθεί επαρκή στοιχεία!", "Error!", 
                    JOptionPane.ERROR_MESSAGE);
        }    
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel7 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Πληρωμή");
        setResizable(false);

        jLabel1.setText("Αρ. Κάρτας : ");

        jTextField1.setEditable(editable);
        jTextField1.setFocusable(editable);
        jTextField1.setSelectionColor(new java.awt.Color(240, 240, 240));
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });
        jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextField1KeyPressed(evt);
            }
        });
        if(editable==true){
            jTextField1.setBackground(new java.awt.Color(255, 255, 255));
        }
        else{
            jTextField1.setBackground(new java.awt.Color(255, 255, 0));
        }

        jLabel2.setText("Αρ. Πινακίδας : ");

        jTextField2.setEditable(editable);
        jTextField2.setFocusable(editable);
        jTextField2.setSelectionColor(new java.awt.Color(240, 240, 240));
        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });
        if(editable==true){
            jTextField2.setBackground(new java.awt.Color(255, 255, 255));
        }
        else{
            jTextField2.setBackground(new java.awt.Color(255, 255, 0));
        }

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/save.gif"))); // NOI18N
        jButton1.setText("Πληρωμή");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel3.setText("Υπόλοιπο : ");

        jTextField3.setEditable(false);
        jTextField3.setBackground(new java.awt.Color(255, 255, 0));
        jTextField3.setForeground(new java.awt.Color(0, 51, 204));
        jTextField3.setText("0.0");
        jTextField3.setFocusable(false);
        jTextField3.setSelectionColor(new java.awt.Color(240, 240, 240));
        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });

        jLabel4.setText("Ποσό Πληρωμής :  ");

        jTextField4.setText("0.0");
        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });

        jLabel5.setText("Νέο Υπόλοιπο : ");

        jTextField5.setEditable(false);
        jTextField5.setBackground(new java.awt.Color(255, 255, 0));
        jTextField5.setForeground(new java.awt.Color(0, 51, 153));
        jTextField5.setText("0.0");
        jTextField5.setFocusable(false);
        jTextField5.setSelectionColor(new java.awt.Color(240, 240, 240));
        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(evt);
            }
        });

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/eraser.gif"))); // NOI18N
        jButton2.setText("Καθαρισμός");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cancel.gif"))); // NOI18N
        jButton3.setText("Ακυρο");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search.gif"))); // NOI18N
        jButton4.setToolTipText("Αναζήτηση ");
        jButton4.setEnabled(editable);
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel7.setText("Κατώτερο όριο φόρτισης 10 Ευρώ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator2)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createSequentialGroup()
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jLabel4)
                                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jButton3)
                                        .addGap(14, 14, 14)
                                        .addComponent(jButton1)))
                                .addGap(18, 18, 18)
                                .addComponent(jButton2))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(15, 15, 15)
                                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jTextField3, jTextField4, jTextField5});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel7)
                .addGap(14, 14, 14)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton3)
                    .addComponent(jButton2))
                .addContainerGap(66, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField2ActionPerformed

    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed
        // TODO add your handling code here:
        try{
            if(Double.parseDouble(jTextField4.getText())>=10||(Double.parseDouble(jTextField5.getText())-
                    Double.parseDouble(jTextField3.getText())+Double.parseDouble(jTextField4.getText()))>=10){
            jTextField5.setText(String.valueOf(Double.parseDouble(jTextField5.getText())+
                    Double.parseDouble(jTextField4.getText())));
            jTextField4.setText("");
            }
            else{
                if((Double.parseDouble(jTextField5.getText()) -
                    Double.parseDouble(jTextField3.getText()) + Double.parseDouble(jTextField4.getText()))<0){
                    JOptionPane.showMessageDialog(rootPane,"Δεν μπορείτε να αφαιρέσετε χρήματα από τον λογαριασμό!", "Error!", 
                            JOptionPane.ERROR_MESSAGE);
                }
                else{
                    JOptionPane.showMessageDialog(rootPane,"Κατώτερο όριο φόρτισης 10 Ευρώ!", "Error!", 
                            JOptionPane.ERROR_MESSAGE);
                }
                jTextField4.setText("");   
            }
        }
        catch(Exception ex){
            JOptionPane.showMessageDialog(rootPane,"Λάθος εισαγωγή στοιχείων!", "Error!", 
                JOptionPane.ERROR_MESSAGE);
            jTextField4.setText("");
        }
    }//GEN-LAST:event_jTextField4ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        try{
            updateFields();
        }
        catch(Exception ex){
           JOptionPane.showMessageDialog(rootPane,"Δεν έχουν εισαχθεί επαρκή στοιχεία!", "Error!", 
                    JOptionPane.ERROR_MESSAGE);
        }    
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        try{
            pay1=new Payment();
            em.persist(pay1);
            pay1.setCardId(vehicle1.getCardId());
            pay1.setPaymentTimestamp(new Date());
            pay1.setNewBalance(BigDecimal.valueOf(Double.parseDouble(jTextField5.getText())));
            pay1.setStationId(Session.loginUser.getStationId());
            pay1.setOldBalance(BigDecimal.valueOf(Double.parseDouble(jTextField3.getText())));
            vehicle1.getCardId().getPaymentList().add(pay1);
            vehicle1.getCardId().setBalance(Double.parseDouble(jTextField5.getText()));
            try{
                em.getTransaction().commit();
                em.getTransaction().begin();
                }
                catch(Exception ex){
                    JOptionPane.showMessageDialog(rootPane,ex.getMessage(), "Error!", 
                            JOptionPane.ERROR_MESSAGE);
                }
                if(editable==false){
                    MyWindowEvent we = new MyWindowEvent(this, WindowEvent.WINDOW_CLOSED,true);
                    for (WindowListener l : this.getWindowListeners()) {
                        l.windowClosed(we);
                    }
                    this.setVisible(false);
                }
                else{
                    dispose();
                }
                
        }
        catch(Exception ex){
            JOptionPane.showMessageDialog(rootPane,"Δεν έχουν εισαχθεί επαρκή στοιχεία!", "Error!", 
                    JOptionPane.ERROR_MESSAGE);
        }
       
        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
         try{
        em.getTransaction().rollback();
        }
        catch(Exception ex){
            JOptionPane.showMessageDialog(rootPane,ex.getMessage(), "Error!", 
                    JOptionPane.ERROR_MESSAGE);
        }
        try{
            em.getTransaction().begin();
            if(editable==false){
                MyWindowEvent we = new MyWindowEvent(this, WindowEvent.WINDOW_CLOSED,false);
                for (WindowListener l : this.getWindowListeners()) {
                    l.windowClosed(we);
                }
                this.setVisible(false);
            }
            else{
                dispose();
            }
        }
        catch(Exception ex){
            JOptionPane.showMessageDialog(rootPane,ex.getMessage(), "Error!", 
                    JOptionPane.ERROR_MESSAGE);
        }
        
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField5ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here: Search Button
        
      if(!jTextField1.getText().equals("") && (!jTextField2.getText().equals(""))){
            try{
                query1 = em.createQuery("select v from Vehicle v where v.cardId.barcode=:barcode "
                        + "and v.regNumber=:regNumber").setParameter("barcode",Integer.parseInt
                        (jTextField1.getText())).setParameter("regNumber",jTextField2.getText());
                vehicle1 =  (Vehicle)query1.getSingleResult();
                updateFields();
            }
            catch(Exception ex){
                JOptionPane.showMessageDialog(rootPane,"Δεν βρέθηκε όχημα με τα στοιχεία που δόθηκαν!", "Error!", 
                    JOptionPane.ERROR_MESSAGE);
                jTextField1.setText("");
                jTextField2.setText("");
                resetFields();
            }
        }
        else{
           JOptionPane.showMessageDialog(rootPane,"Δεν έχουν εισαχθεί επαρκή στοιχεία προς αναζήτηση!", "Error!", 
                     JOptionPane.ERROR_MESSAGE); 
            if ( jTextField1.getText().equals("")){
                jTextField1.grabFocus();}else
            {
                jTextField2.grabFocus();
            }
        }   
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyPressed
        // TODO add your handling code here:
         char ch = evt.getKeyChar();
          if ( ch < '0' || ch > '9' ) {
            JOptionPane.showMessageDialog(this, "Πρέπει να εισάγετε μόνο αριθμούς!",
                                          "Σφάλμα",JOptionPane.ERROR_MESSAGE);
            evt.consume();
            jTextField1.setText("");
            jTextField1.grabFocus();
          }
    }//GEN-LAST:event_jTextField1KeyPressed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PaymentForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PaymentForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PaymentForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PaymentForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PaymentForm().setVisible(true);
            }
        });
    }
    
    
    private void updateFields() throws Exception{
        jTextField3.setText(String.valueOf(vehicle1.getCardId().getBalance()));
        jTextField4.setText("");
        jTextField5.setText(String.valueOf(vehicle1.getCardId().getBalance()));
    }
    
    private void resetFields(){
        jTextField3.setText("0.0");
        jTextField4.setText("0.0");
        jTextField5.setText("0.0");
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    // End of variables declaration//GEN-END:variables
    Boolean editable;
    Vehicle vehicle1;
    Payment pay1;
    EntityManager em;
    int barCode;
    String regNumber;
    Query query1;
    List list1;
    
}
